package com.xpgk.mvc.statistic.employeePerformanceList;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.codeSet.Code;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.scallVisit.ScallVisitXLS;

public class EmployeePerformanceListController extends BaseController {
	
	
	private EmployeePerformanceListService employeePerformanceListService;
	
	/*
	 * 页面跳转
	 */
	public void index(){
		setAttr("curOrgan", Organization.dao.findById(getCUserOrganIds()));
		setAttr("parts", Code.cacheGetChild(Code.fwbw_ids));
		setAttr("colspan", Code.cacheGetChild(Code.fwbw_ids).size());
		render("employeePerformanceList.html");
	}
	
	/*
	 * 店员资料查询
	 */
	public void employeeQuery(){
		String organIds = getPara("organIdsEmployee");
		String startdate = getPara("startdate");
		String enddate = getPara("enddate");
		List<Record> result = employeePerformanceListService.employeeQuery(organIds, startdate, enddate);
//		for(Record f : result){
//			System.out.println(f);
//		}
		renderJson(result);
	}
	/*
	 * 店员资料查询导出Excel
	 */
	public void excel(){
		String organIds = getPara("organIdsEmployee");
		String startdate = getPara("startdate");
		String enddate = getPara("enddate");
		List<Record> result = employeePerformanceListService.employeeQuery(organIds, startdate, enddate);
		Organization organ = Organization.dao.findById(organIds);//门店
		String search_organIdsEmployee =organ.getStr(Organization.column_name).equals("")?"":("店面名称："+organ.getStr(Organization.column_name)+"，");
		String search = search_organIdsEmployee+"起始日期："+startdate+"，终止日期："+enddate;
		List<Code> cacheGetChild = Code.cacheGetChild(Code.fwbw_ids);
		render(new EmployeePerformanceListXLS(result,"店员业绩统计表",search,cacheGetChild));
	}
}
